package com.soft.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.soft.entity.Worker;
import com.soft.service.WorkerService;

@RestController
@RequestMapping("/worker")
public class WorkerController {
	@Autowired
	private WorkerService workerService;
	@RequestMapping("/queryAllWorker")
	public List<Worker> queryAll(){
		return workerService.queryAll();
	}
	
	@RequestMapping("/queryBySex")
	public List<Worker> queryBySex(String workerSex){
		return workerService.queryBySex(workerSex);
	}
	
	@RequestMapping("/insertOne")
	public String insertOne(String workerName,String workerSex,String workerPhone){
		int num =  workerService.insertOne(workerName,workerSex,workerPhone);
		if(num == 1)
		{
			return workerName + "加入成功";
		}else {
			return workerName + "加入失败";
		}
	}
	
	@RequestMapping("/deleteById") 
	public String deleteById(long workerId){
		int num =  workerService.deleteById(workerId);
		if(num == 1)
		{
			return "删除成功";
		}else {
			return "删除失败";
		}
	}
	
	@RequestMapping("/queryByWorkerLiveAddress")
	public List<Worker> queryByWorkerLiveAddress(String liveAddress) {
		return workerService.queryByWorkerLiveAddress(liveAddress);
	}
}
